﻿using System;

namespace Mates
{
    public struct Vector4i
    {
        public Vector4i(int x, int y, int z, int w)
        {
            this.x = x;
            this.y = y;
            this.z = z;
            this.w = w;
        }
        public int x;
        public int y;
        public int z;
        public int w;
        public static Vector4i Zero = new Vector4i(0, 0, 0,0);

        public override bool Equals(object obj)
        {
            if (obj is Vector4i)
            {
                Vector4i other = (Vector4i)obj;
                return this.x == other.x && this.y == other.y && this.z == other.z && this.w == other.w;
            }
            return base.Equals(obj);
        }
        public static bool operator ==(Vector4i a, Vector4i b)
        {
            return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
        }
        public static bool operator !=(Vector4i a, Vector4i b)
        {
            return !(a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w);
        }

        public static Vector4i operator +(Vector4i a, Vector4i b)
        {
            return new Vector4i(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
        }

        public override int GetHashCode()
        {
            int hash = 22;
            unchecked
            {
                hash = hash * 37 + x;
                hash = hash * 37 + y;
                hash = hash * 37 + z;
                hash = hash * 37 + w;
            }
            return hash;
        }
        public int GetDistanceSquared(Vector4i vector2)
        {
            int dx = this.x - vector2.x;
            int dy = this.y - vector2.y;
            int dz = this.z - vector2.z;
            int dw = this.w - vector2.w;
            return (dx * dx) + (dy * dy) + (dz * dz) + (dw*dw);
        }
        public override string ToString()
        {
            return ("vector4i (" + x + "," + y + "," + z + ","+w+")");
        }
    }

}
